package com.icoolkj.ms.api.pay.feign;

import com.icoolkj.ms.common.core.constant.ServiceNameConstants;
import com.icoolkj.ms.common.core.response.ServerResponseEntity;
import com.icoolkj.ms.api.pay.dto.MemberRechargeDTO;
import com.icoolkj.ms.api.pay.model.MemberRecharge;
import com.icoolkj.ms.api.pay.vo.RechargePackageVO;
import com.icoolkj.ms.api.pay.vo.RechargeResultVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 会员充值服务Feign客户端接口
 *
 * @author icoolkj
 */
@FeignClient(name = ServiceNameConstants.PAY_SERVICE, contextId = "memberRechargeClient")
public interface MemberRechargeFeignClient {

    /**
     * 获取充值套餐
     *
     * @return 套餐列表
     */
    @GetMapping("/member/recharge/packages")
    ServerResponseEntity<List<RechargePackageVO>> getRechargePackages();

    /**
     * 创建充值订单
     *
     * @param memberId 会员ID
     * @param rechargeDTO 充值信息
     * @return 充值结果
     */
    @PostMapping("/member/recharge/create")
    ServerResponseEntity<RechargeResultVO> createRechargeOrder(@RequestParam("memberId") Long memberId, 
                                                 @RequestBody MemberRechargeDTO rechargeDTO);

    /**
     * 获取支付参数
     *
     * @param orderNo 订单号
     * @param payType 支付类型
     * @return 支付参数
     */
    @GetMapping("/member/payment/params")
    ServerResponseEntity<Map<String, String>> getPaymentParams(@RequestParam("orderId") String orderNo,
                                                @RequestParam("payType") String payType);

    /**
     * 查询订单状态
     *
     * @param orderNo 订单号
     * @return 订单状态
     */
    @GetMapping("/member/recharge/status/{orderId}")
    ServerResponseEntity<String> getOrderStatus(@PathVariable("orderId") String orderNo);

    /**
     * 查询充值记录
     *
     * @param memberId 会员ID
     * @return 充值记录列表
     */
    @GetMapping("/member/recharge/list")
    ServerResponseEntity<List<MemberRecharge>> getRechargeRecords(@RequestParam("memberId") Long memberId);

    /**
     * 查询充值订单详情
     *
     * @param orderNo 订单号
     * @return 充值订单详情
     */
    @GetMapping("/member/recharge/detail/{orderNo}")
    ServerResponseEntity<MemberRecharge> getRechargeDetail(@PathVariable String orderNo);

    /**
     * 取消充值订单
     *
     * @param memberId 会员ID
     * @param orderNo 订单号
     * @return 操作结果
     */
    @PostMapping("/member/recharge/cancel/{orderNo}")
    ServerResponseEntity<Boolean> cancelRechargeOrder(@RequestParam("memberId") Long memberId, 
                                       @PathVariable String orderNo);
    
    /**
     * 处理支付结果回调
     *
     * @param payType 支付类型
     * @param params 回调参数
     * @return 处理结果
     */
    @PostMapping("/internal/member/recharge/callback/{payType}")
    ServerResponseEntity<Boolean> handlePayNotify(@PathVariable String payType, 
                                  @RequestBody Map<String, String> params);
} 